package com.example.cms.utils;


public class Result {

    public Integer status=SUCCESS_CODE;

    public static Integer SUCCESS_CODE=200;

    public static Integer ERROR_CODE=500;

    public String msg="操作成功";

    public Object data=null;

    public Result( Object data) {
        this.data = data;
    }

    //成功响应状态
    public Result(Integer status, String msg, Object data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public Result(Integer status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    public Result(String msg, Object data) {
        this.msg = msg;
        this.data = data;
    }

    public static Result ok(Object data){
        return new Result(data);
    }

    public static Result ok(String msg,Object data){
        return new Result(msg,data);
    }

    //构造重载
    public Result(){

    }

    public static Result ok(){
        return new Result();
    }

    public static Result ok(Integer status,String msg,Object data){
        return new Result(status,msg,data);
    }



    public static Result fail(String msg){
        return new Result(ERROR_CODE,msg,null);
    }


    public static Result fail(){
        return new Result(ERROR_CODE,"操作失败");
    }

    //失败响应
    public static Result fail(Integer status,String msg){
        return new Result(status,msg,null);
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
